# Maintainer: Alexey Pavlov <alexpux@gmail.com>

_realname=wavpack
pkgbase=mingw-w64-${_realname}
pkgname="${MINGW_PACKAGE_PREFIX}-${_realname}"
pkgver=5.8.1
pkgrel=1
pkgdesc="Audio compression format with lossless, lossy and hybrid compression modes (mingw-w64)"
arch=('any')
mingw_arch=('mingw32' 'mingw64' 'ucrt64' 'clang64' 'clangarm64')
msys2_repository_url='https://github.com/dbry/WavPack/'
url="https://www.wavpack.com/"
msys2_references=(
  "cpe: cpe:/a:wavpack:wavpack"
  "cpe: cpe:/a:wavpack_project:wavpack"
)
license=('spdx:BSD-3-Clause')
makedepends=(
  "${MINGW_PACKAGE_PREFIX}-cc"
  "${MINGW_PACKAGE_PREFIX}-autotools"
)
depends=("${MINGW_PACKAGE_PREFIX}-gcc-libs")
source=("https://github.com/dbry/WavPack/releases/download/${pkgver}/wavpack-${pkgver}.tar.xz")
sha256sums=('7322775498602c8850afcfc1ae38f99df4cbcd51386e873d6b0f8047e55c0c26')

build() {
  mkdir -p "${srcdir}/build-${MSYSTEM}" && cd "${srcdir}/build-${MSYSTEM}"
  ../${_realname}-${pkgver}/configure \
    --prefix=${MINGW_PREFIX} \
    --build=${MINGW_CHOST} \
    --host=${MINGW_CHOST} \
    --enable-shared \
    --enable-static

  make
}

package() {
  cd "${srcdir}/build-${MSYSTEM}"
  make -j1 DESTDIR="${pkgdir}" install
  find "${pkgdir}${MINGW_PREFIX}" -name '*.def' -o -name '*.exp' | xargs -rtl1 rm
  install -vDm644 "${srcdir}/${_realname}-${pkgver}/COPYING" "${pkgdir}${MINGW_PREFIX}/share/licenses/${_realname}/COPYING"
}
